package com.epro.dx.pullview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ScrollView;

public class PullToRefreshScrollView extends PullToRefreshBase<ScrollView> {

	 public PullToRefreshScrollView(Context context)
	    {
	        super(context);
	    }
	    
	    public PullToRefreshScrollView(Context context, AttributeSet attrs)
	    {
	        super(context, attrs);
	    }
	    
	    public PullToRefreshScrollView(Context context, Mode mode)
	    {
	        super(context, mode);
	    }
	    
	    public PullToRefreshScrollView(Context context, Mode mode, AnimationStyle animStyle)
	    {
	        super(context, mode, animStyle);
	    }
	@Override
	public com.epro.dx.pullview.PullToRefreshBase.Orientation getPullToRefreshScrollDirection() {
		return Orientation.VERTICAL;
	}

	@Override
	protected ScrollView createRefreshableView(Context context,
			AttributeSet attrs) {
		ScrollView scrollView = new ScrollView(context);
//		scrollView.setId(android.R.id.s)
        return scrollView;
	}

	@Override
	protected boolean isReadyForPullEnd() {
		 View scrollViewChild = mRefreshableView.getChildAt(0);
	        if (null != scrollViewChild) {
	            return mRefreshableView.getScrollY() >= (scrollViewChild.getHeight() - getHeight());
	        }
	        
	        return false;
	}

	@Override
	protected boolean isReadyForPullStart() {
		return mRefreshableView.getScrollY() == 0;
		
	}


}
